// 导入组件
import Vue from 'vue';
import Router from 'vue-router';

// 首页
import index from '@/views/index';
/**
 * 基础菜单
 */
import pagecustom from '@/views/pageMangent/pagecustom';
import pageList from '@/views/pageMangent/pageList';
import appTypeMangent from '@/views/typeMangent/appTypeMangent';
import pageTypeMangent from '@/views/typeMangent/pageTypeMangent';
import identificationManagement from '@/views/typeMangent/identificationManagement';
import productMangent from '@/views/productMangent/productMangent';
import templateList from '@/views/templateMangent/templateList';
import relationPages from '@/views/templateMangent/relationPages';
import linkType from '@/views/linkMangent/linkType';
import linkDetail from '@/views/linkMangent/linkDetail';
import domainList from '@/views/domainTemplate/domainList';
import domainMore from '@/views/domainTemplate/domainMore';
import ContainerTest from '@/views/container_test';
import PadPage from '@/views/gridContainer/index.vue';
// 启用路由
Vue.use(Router);

const originalPush = Router.prototype.push;
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch((err) => err);
};

// 导出路由
export default new Router({
  routes: [
    {
      path: '/',
      name: '',
      component: index,
      hidden: true,
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/test',
      name: '',
      component: ContainerTest,
      hidden: true,
      meta: {
        requireAuth: false
      }
    },
    {
      path: '/index',
      name: 'Home',
      component: index,
      iconCls: 'el-icon-tickets',
      children: [
        {
          path: '/typeMangent/appTypeMangent',
          name: 'appTypeMangent',
          component: appTypeMangent,
          meta: {
            title: '产品类型管理',
            requireAuth: true
          }
        },
        {
          path: '/typeMangent/pageTypeMangent',
          name: 'pageTypeMangent',
          component: pageTypeMangent,
          meta: {
            title: '页面类型管理',
            requireAuth: true
          }
        },
        {
          path: '/typeMangent/identificationManagement',
          name: 'identificationManagement',
          component: identificationManagement,
          meta: {
            title: '标识管理',
            requireAuth: true
          }
        },
        {
          path: '/productMangent/productMangent',
          name: 'productMangent',
          component: productMangent,
          meta: {
            title: '产品管理',
            requireAuth: true
          }
        },
        {
          path: '/pageMangent/pagecustom',
          name: 'pagecustom',
          component: pagecustom,
          meta: {
            title: '页面装修',
            requireAuth: true
          }
        },
        {
          path: '/pageMangent/pagepadcustom',
          name: 'pagepadcustom',
          component: PadPage,
          meta: {
            title: 'pad页面装修',
            requireAuth: true
          }
        },
        {
          path: '/pageMangent/pageList',
          name: 'pageList',
          component: pageList,
          meta: {
            title: '页面列表',
            requireAuth: true,
            keepAlive: true // 需要被缓存
          }
        },
        {
          path: '/templateMangent/templateList',
          name: 'templateList',
          component: templateList,
          meta: {
            title: '模板列表',
            requireAuth: true
          }
        },
        {
          path: '/templateMangent/relationPages',
          name: 'relationPages',
          component: relationPages,
          meta: {
            title: '模板列表',
            requireAuth: true
          }
        },
        {
          path: '/linkMangent/linkType',
          name: 'linkType',
          component: linkType,
          meta: {
            title: '链接分类',
            requireAuth: true
          }
        },
        {
          path: '/linkMangent/linkDetail',
          name: 'linkDetail',
          component: linkDetail,
          meta: {
            title: '链接详情',
            requireAuth: true
          }
        },
        {
          path: '/domainTemplate/domainList',
          name: 'domainList',
          component: domainList,
          meta: {
            title: '域名列表',
            requireAuth: true
          }
        },
        {
          path: '/domainTemplate/domainMore',
          name: 'domainMore',
          component: domainMore,
          meta: {
            title: '域名详情',
            requireAuth: true
          }
        }
      ]
    }
  ]
});
